package com.xsq.wifi.model;

import android.net.Uri;

import java.util.Locale;
import java.util.concurrent.TimeUnit;

/**
 * 编写人：李振德
 * 创建时间：2025/6/8
 */
public class VideoItem {
    private long id;
    private String name;
    private long duration;
    private long size;
    private Uri contentUri;
    private String path;
    private boolean isSelected;

    public VideoItem(long id, String name, long duration, long size, Uri contentUri, String path) {
        this.id = id;
        this.name = name;
        this.duration = duration;
        this.size = size;
        this.contentUri = contentUri;
        this.path = path;
        this.isSelected = false;
    }

    // Getters and Setters
    public long getId() { return id; }
    public String getName() { return name; }
    public long getDuration() { return duration; }
    public long getSize() { return size; }
    public Uri getContentUri() { return contentUri; }
    public String getPath() { return path; }
    public boolean isSelected() { return isSelected; }
    public void setSelected(boolean selected) { isSelected = selected; }

    // 格式化方法
    public String getFormattedDuration() {
        return String.format(Locale.getDefault(), "%02d:%02d",
                TimeUnit.MILLISECONDS.toMinutes(duration),
                TimeUnit.MILLISECONDS.toSeconds(duration) -
                        TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))
        );
    }

    public String getFormattedSize() {
        return String.format(Locale.getDefault(), "%.1f MB", (double) size / (1024 * 1024));
    }
}
